feat: allow overriding YamlDotNet settings#1335
feat: allow overriding YamlDotNet settings#1335IvanJosipovic wants to merge 4 commits intokubernetes-client:masterfrom
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: IvanJosipovic The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Codecov Report
❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more. @@ Coverage Diff @@
## master #1335 +/- ##
=========================================
Coverage ? 69.74%
=========================================
Files ? 96
Lines ? 2720
Branches ? 0
=========================================
Hits ? 1897
Misses ? 823
Partials ? 0 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
|
I converted the logic to use an event. It can be tested like this: using k8s;
using System.Text.Json.Nodes;
using YamlDotNet.Serialization;
using YamlDotNet.System.Text.Json;
KubernetesYamlConfiguration.SeralizerEvent += KubernetesYamlConfiguration_SeralizerEvent;
void KubernetesYamlConfiguration_SeralizerEvent(object? sender, SerializerBuilder e)
{
e.WithTypeConverter(new SystemTextJsonYamlTypeConverter(true))
.WithTypeInspector(x => new SystemTextJsonTypeInspector(x));
}
KubernetesYamlConfiguration.DeseralizerEvent += KubernetesYamlConfiguration_DeseralizerEvent;
void KubernetesYamlConfiguration_DeseralizerEvent(object? sender, DeserializerBuilder e)
{
e.WithTypeConverter(new SystemTextJsonYamlTypeConverter())
.WithTypeInspector(x => new SystemTextJsonTypeInspector(x));
}
var obj = KubernetesYaml.LoadFromString<JsonObject>(File.ReadAllText("helm-release.yaml"));
var yaml = KubernetesYaml.Serialize(obj);
Console.ReadLine(); |
|
close as of #1498 |
|
@tg123, can we please re-open this PR? |
This PR allows overriding the default YamlDotNet settings by adding a new KubernetesYamlConfiguration class.
I'm not able to test this as its static.